import numpy as np
import os
import os.path as osp
import cv2


def comp_two_dir_img(dir1, dir2):
    res_dir_py, res_dir_cpp = dir1, dir2
    res_file_names = os.listdir(res_dir_py)

    for name in res_file_names:
        file_path_py = osp.join(res_dir_py, name)
        file_path_cpp = osp.join(res_dir_cpp, name)
        assert osp.exists(file_path_cpp), '{} 不存在'.format(file_path_cpp)

        mat_py = cv2.imread(file_path_py)
        mat_cpp = cv2.imread(file_path_cpp)
        assert np.array_equal(mat_py, mat_cpp), '{} 与 {} 结果不一致'.format(file_path_py, file_path_cpp)


res_dir_py = '/culn/crop_py'
res_dir_cpp = '/culn/crop_cpp'
res_dir_triton = '/culn/crop_triton'
# comp_two_dir_img(res_dir_py, res_dir_cpp)
comp_two_dir_img(res_dir_py, res_dir_triton)

print('finish')
